package webEquipeRechercheGwt.ejbServer.metier;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name="TEAM_MEMBER")
public class TeamMemberPeriod implements Serializable {
	
	private static final long serialVersionUID = 7260528948181651973L;
	private int id;
	private Person member;
	private Team team;
	private Period period;
	
	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	@OneToOne
	@Transient
	public Person getMember() {
		return member;
	}
	public void setMember(Person member) {
		this.member = member;
	}
	@ManyToOne
	@Transient
	public Team getTeam() {
		return team;
	}
	public void setTeam(Team team) {
		this.team = team;
	}
	@OneToOne
	@Transient
	public Period getPeriod() {
		return period;
	}
	public void setPeriod(Period period) {
		this.period = period;
	}
	
	public boolean equals(TeamMemberPeriod p){
		return p.getId()==getId();
	}
	
	@Override
	public boolean equals(Object p){
		try{
			TeamMemberPeriod param = (TeamMemberPeriod) p;
			return param.getId()==getId();
		}
		catch(ClassCastException e){
			return false;
		}
	}
}
